<?php

namespace App\Models\Cashbook;

use App\Models\BaseModel;
use App\Models\Traits\KfSoftDeletes;
use App\Models\Traits\KfUid;

class CashbookCycleModel extends BaseModel
{
    use KfUid;
    use KfSoftDeletes;

    protected $table = "cashbook_cycle";

    protected $fillable = [
        'id',
        'shopId',
        'userId',
        'cycleType',
        'type',
        'category',
        'amount',
        'startTime',
        'endTime',
        'nextTime',
        'status',
        'remark',
        'isDeleted',
        'createdAt',
        'createdByUid',
        'updatedAt',
        'updatedByUid',
    ];


    const CYCLE_TYPE_DEFAULT   = 0;//不重复
    const CYCLE_TYPE_DAY       = 1;
    const CYCLE_TYPE_WEEK      = 2;
    const CYCLE_TYPE_MONTH     = 3;
    const CYCLE_TYPE_QUARTERLY = 4;
    const CYCLE_TYPE_YEAR      = 5;

    const CYCLE_TYPE_TEXT_MAPPING = [
        self::CYCLE_TYPE_DAY       => '每天',
        self::CYCLE_TYPE_WEEK      => '每周',
        self::CYCLE_TYPE_MONTH     => '每月',
        self::CYCLE_TYPE_QUARTERLY => '每季度',
        self::CYCLE_TYPE_YEAR      => '每年',
    ];

    const STATUS_DEAL_ING = 1;
    const STATUS_PAUSE    = 2;
    const STATUS_SUCCESS  = 3;

    const STATUS_TEXT_MAPPING = [
        self::STATUS_DEAL_ING => '可执行',
        self::STATUS_PAUSE    => '暂停',
        self::STATUS_SUCCESS  => '完成',
    ];

    public static function insertData(array $data)
    {
        return self::query()->create($data);
    }

}
